// 可获取项目下所有云服务器详情的列表。
package aecs

import (
	"fmt"
	"os"

	"github.com/aliyun/alibaba-cloud-sdk-go/services/ecs"
)

// 可获取项目下所有云服务器详情的列表。
// 返回时间略长，如需快速响应，请参考“查询云服务器基础信息列表”API。
func DescribeInstances() {

	client, err := ecs.NewClientWithAccessKey("Southwest08", "7bcbc1983a894daaa917ce5576840ac2", "64a00ec11ae64723a141881880ef23d9")
	client.Domain = "175.155.64.67" //pay attention the port number just for easy use.
	client.GetConfig().Debug = true
	client.SetLogger("debug", "AlibabaCloud", os.Stdout, "")

	if err != nil {
		panic(err)
	}
	request := ecs.CreateDescribeInstancesRequest()
	//request := ecs.CreateDescribeImagesRequest()
	request.Method = "GET"
	request.Port = "8788"

	// request.InstanceType = "VGPU1R9001M"
	// request.ImageId = "30348f0d-326e-4f1d-823e-bc110896fdaa"

	dir, err := client.DescribeInstances(request)
	if err != nil {
		//fmt.Println(err)
	}

	fmt.Println(dir.GetHttpContentString())
}
